package cn.liumouren.jzxd.controller;


import cn.liumouren.jzxd.common.utils.PageUtils;
import cn.liumouren.jzxd.common.utils.R;
import cn.liumouren.jzxd.entity.MerchantApply;
import cn.liumouren.jzxd.service.MerchantApplyService;
import cn.liumouren.jzxd.utils.QueryUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * (MerchantApply)表控制层
 *
 * @author makejava
 * @since 2021-01-23 12:52:46
 */
@RestController
@RequestMapping("/merchantApply")
@Api(tags = "商家申请")
public class MerchantApplyController {

    @Autowired
    private MerchantApplyService merchantApplyService;

    @ApiOperation("万能查询")
    @RequestMapping(value = "/customQuery", method = RequestMethod.GET)
    public R getSceneNames(@RequestParam Map<String, Object> map) {
        PageUtils result = QueryUtil.getResult(merchantApplyService, map);
        return R.ok("查询成功", result);
    }

    /**
     * 根据id查询
     */
    @GetMapping("/{id}")
    public R findById(@PathVariable Serializable id) {
        return R.ok().put("data", merchantApplyService.getById(id));
    }

    /**
     * 新增
     */
    @PostMapping("/save")
    public R save(@RequestBody MerchantApply merchantApply) {
        merchantApplyService.save(merchantApply);
        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping
    public R update(@RequestBody MerchantApply merchantApply) {
        merchantApplyService.updateById(merchantApply);
        return R.ok();
    }

    /**
     * 批量删除
     */
    @DeleteMapping
    public R delete(@RequestParam("idList") List<Serializable> idList) {
        merchantApplyService.removeByIds(idList);
        return R.ok();
    }
}